#ifndef CACKMANAGER_H
#define CACKMANAGER_H

#include "message.h"
#include "SSMsgStruct.h"
#include "extdef.h"

namespace qb{
    typedef qb::proto::Message RawMessage;
    void ClearQpidQueue();
    struct SSPROTOAPI AckNotify{
        bool		m_notify_reg;		// UpdateLocalMessageCache返回值
        bool		m_need_memory;		// 是否需要内存
        int			m_benchmark_id;
        SSAckMsg	m_ack;				//
        RawMessage*	m_message;			// 可能为空
        // 可能得附带原生消息	// 部分模块需要 ss::proto::Message
        AckNotify():m_notify_reg(true),m_need_memory(true),m_message(0){
            memset(&m_ack,0,sizeof(m_ack));
        }
        AckNotify(const SSAckMsg& ack,bool needMemory,bool notifyReg):
        m_need_memory(needMemory),m_notify_reg(notifyReg),m_ack(ack){}
        AckNotify(const AckNotify& an){Copy(an);}
        AckNotify& operator=(const AckNotify& an){Copy(an);return *this;}
        void Copy(const AckNotify& an){m_notify_reg = an.m_notify_reg;
        m_message = an.m_message;
        m_benchmark_id=an.m_benchmark_id;
        m_need_memory=an.m_need_memory;memcpy(&m_ack,&an.m_ack,sizeof(SSAckMsg));}
    };

    class SSPROTOAPI CAckBufAllocator{
    public:
        static void* Alloc(AckNotify& ack);
        static void  Free(AckNotify& ack);
    };
    enum kPushMergeMode{
        kPushMergeModeNone,
        kPushMergeModeOnlyLast,
        kPushMergeModeWholeList
    };
}


#endif // CACKMANAGER_H
